/* const {http,handleStar,handleStr}=require("../../utils/http")

Page({
  data: {
    movie:""
  },
  onLoad() {
    var movie=[];
    var url=`http://47.108.197.28:4000/api/movie/top250`
   http({
     url,
     success:res=>{
      // console.log(res);
      var res=res.data.res;
      res.forEach(item=>{
        // console.log(item);
        var{title,rating,pic,_id}=item;
        movie.push({
          title:handleStr(title),
          pic,
          rating,
          star:handleStar(rating),
          _id
        })
      })
      this.setData({
        movie
      })
     }
   })
  },
  handleItem(event){
    console.log(event.currentTarget.dataset);
    var {aid}=event.currentTarget.dataset;
    wx:wx.navigateTo({
      url:`/pages/detail/detail?id=${aid}`
    })
  }
})
 */

const {getTop250Http} = require("../../utils/http")
Page({
   data:{
       movies:{},
       movies:[]
   },
   onLoad(){
       wx.showLoading({
           title:"数据正在加载中"
       });
       getTop250Http().then(res=>{
           wx.hideLoading();
           this.handleTop250HttpData(res)
       })
   },
   handleTop250HttpData(res){
      console.log(res)
    //   console.log(res.data.res)
      this.setData({
          movies:res.data.res
      })
   },
   handleItem(event){
       var {aid} = event.currentTarget.dataset;
       wx.navigateTo({
           url: `/pages/detail/detail?id=${aid}`
       });
   }
})